#include "VectorTest.h"

//CPPUNIT_TEST_SUITE_REGISTRATION (VectorTest);

void VectorTest::setUp(void) {
	// set up test environment (initializing objects)
	x = 10;
	y = 20;
	vec2 = new common::Vector(x, y);
	vec3 = new common::Vector(y, x);
}

void VectorTest::tearDown(void) {
	// finally delete objects
	delete vec2;
	delete vec3;
}

void VectorTest::testFunction(void) {

	common::Vector vec((*vec2) + (*vec3));
	CPPUNIT_ASSERT_EQUAL(x+y,vec.getX());
	CPPUNIT_ASSERT_EQUAL(x+y,vec.getY());

	common::Vector veca((*vec2) - (*vec3));
	CPPUNIT_ASSERT_EQUAL(x-y,veca.getX());
	CPPUNIT_ASSERT_EQUAL(y-x,veca.getY());

	skreal vecb = (*vec2)*(*vec3);
	CPPUNIT_ASSERT_EQUAL(2*x*y,vecb);

	CPPUNIT_ASSERT_EQUAL(x*x-y*y,(*vec2)^(*vec3));

	CPPUNIT_ASSERT_EQUAL(vec2->length(),vec3->length());

	common::Vector vecd(vec2->unit());

	CPPUNIT_ASSERT(abs(1.0f-vecd.length())<1e-6);

}

